// 获取全局应用程序实例对象
const app = getApp();
const {get,post} = app.utils.request;
const {merchant_info} = app.utils.config;

// 创建页面实例对象
Page({
	// 页面的初始数据
	data: {
		title: 'detail',
		indicatorDots: true,
		indicatorColor: 'rgba(255,255,255,1)',
		indicatorActiveColor: 'rgba(255,255,255,.5)',
		autoplay: true,
		markers: [{
            iconPath: require('../../images/face.png'),
            id: 0,
            latitude: 23.099994,
            longitude: 113.324520,
            width: 50,
            height: 50
        }],
        levels: [{
        	name: '金牌诚信',
        	icon: 'gold'
        },{
        	name: '银牌诚信',
        	icon: 'sliver'
        },{
        	name: '铜牌诚信',
        	icon: 'copper'
        }],
        merchant: {},
        aptitudeShow: false
	},

	// 生命周期函数--监听页面加载
	onLoad(options) {
		var that = this;
		const {id} = options;
		post({path: `${merchant_info}`},{merchant_id:id})
		.then((res)=>{
			that.setData({
				'title': res.data.title,
				'merchant': res.data
			});
		});
	},

	// 页面分享设置
	onShareAppMessage() {
		return {
			title: 'share title',
			path: 'pages/detail/detail',
		};
	},

	callPhone(evt) {
		var number = evt.currentTarget.dataset.number;
		wx.makePhoneCall({
			phoneNumber: number
		})
	},

	openMap(evt) {
		const {latitude,longitude} = evt.currentTarget.dataset;
		wx.openLocation({
			latitude: Number(latitude),
			longitude: Number(longitude),
			scale: 28
		});
	},

	showAptitude(evt) {
		this.setData({
			aptitudeShow: true
		});
	},
	closeAptitude(){
		this.setData({
			aptitudeShow: false
		});
	}
});